package org.example.what_mall.vo;

import lombok.Data;
import org.example.what_mall.dto.GoodsOrderDTO;
import org.example.what_mall.entity.Goods;
import org.example.what_mall.entity.Order;
import org.example.what_mall.entity.Spec;

import java.time.LocalDateTime;

@Data
public class OrderVO {
    private Integer id;
    private GoodsOrderDTO goods;
    private Integer goodsNum;
    private Integer amount;
    private LocalDateTime createtime;
    private Integer state;

    public static OrderVO of(Order order, Goods goods, Spec spec) {

        GoodsOrderDTO goodsOrderDTO = GoodsOrderDTO.of(goods, spec);

        OrderVO orderVO = new OrderVO();
        orderVO.setId(order.getId());
        orderVO.setGoodsNum(order.getNum());
        orderVO.setAmount(order.getAmount());
        orderVO.setCreatetime(order.getCreatetime());
        orderVO.setState(order.getState());
        orderVO.setGoods(goodsOrderDTO);
        return orderVO;

    }
}
